<#import "add_base.ftl" as add/>
<@add.html>
<script type="text/javascript">
  function getmb(c) {
    if(c!="") {
      getJson("getMember?code="+c, function(data){
        if(data.ret) {
          var mc = data.data;
          var fm = getEl("fm_input");
          fm.memberCode.value = mc.memberCode;
          fm.chName.value = mc.memberName;
          fm.enName.value = mc.enName;
          fm.gender.value = mc.gender;
          fm.mobile.value = mc.mobile;
          fm.idType.value = mc.idType;
          fm.idNumber.value = mc.idNumber;
          fm.birthday.value = mc.birthday;
          fm.country.value = mc.country;
          fm.phone.value = mc.phone;
          fm.email.value = mc.email;
          fm.address.value = mc.address;
          fm.memberNote.value = mc.note;
          fm.memberPhoto.value = mc.memberPhoto;
          fm.idCardPhoto.value = mc.idCardPhoto;
          getEl("sp_photo1").innerHTML = mc.memberPhoto?('<img src="${_picPath!}'+mc.memberPhoto+'" style="max-width:120px; max-height:100px;" onclick="window.open(this.src);"/>'):'';
          getEl("sp_photo2").innerHTML = mc.idCardPhoto?('<img src="${_picPath!}'+mc.idCardPhoto+'" style="max-width:120px; max-height:100px;" onclick="window.open(this.src);"/>'):'';

        } else {
          window.alert(data.msg);
          clmb();
        }
      });
    } else {
      clmb();
    }
  }
  function clmb() {
    var fm = getEl("fm_input");
    //fm.memberCode.value = "";
    fm.chName.value = "";
    fm.enName.value = "";
    fm.gender.value = "";
    fm.mobile.value = "";
    fm.idType.value = "";
    fm.idNumber.value ="";
    fm.birthday.value = "";
    fm.country.value = "";
    fm.phone.value = "";
    fm.email.value = "";
    fm.address.value = "";
    fm.memberNote.value = "";
    fm.memberPhoto.value = "";
    fm.idCardPhoto.value = "";
    getEl("sp_photo1").innerHTML = "";
    getEl("sp_photo2").innerHTML = "";
  }

  function showUpload(tp) {
    if(tp==2)
      openWin("../memberContract/upload?tp="+tp, 500, 400);
    else
      openWin("../memberContract/upload?tp="+tp, 650, 450);
  }
  function uploadOk(upl) {
    getEl("fm_input").memberPhoto.value = upl.furl;
    getEl("sp_photo1").innerHTML = '<img src="${_picPath!}'+upl.furl+'" style="max-width:120px; max-height:100px;" onclick="window.open(this.src);"/>';
  }
  function uploadOk2(upl) {
    getEl("fm_input").idCardPhoto.value = upl.furl;
    getEl("sp_photo2").innerHTML = '<img src="${_picPath!}'+upl.furl+'" style="max-width:120px; max-height:100px;" onclick="window.open(this.src);"/>';
  }
</script>

        <tr>
          <th width="85">会员编号</th>
          <td width="160"><input type="text" name="memberCode" value="" req="会员编号" onchange="getmb(this.value);" maxlength="20"></td>
          <th width="85">性别</th>
          <td width="160"><select name="gender"><#if gender??><#list gender as t><option value="${t.id}">${t.name}</option></#list></#if></select></td>
        </tr>
        <tr>
          <th>中文姓名</th>
          <td><input type="text" name="chName" value=""></td>
          <th>英文姓名</th>
          <td><input type="text" name="enName" value=""></td>
        </tr>
        <tr>
          <th>证件号</th>
          <td colspan="3"><select name="idType" req="证件类型"><#if idType??><#list idType as t><option value="${t.id}">${t.name}</option></#list></#if></select>
            <input type="text" name="idNumber" value="" req="证件号" style="width:240px;"></td>
        </tr>
        <tr>
          <th>出生日期</th>
          <td><input type="text" name="birthday" value="" class="date" maxlength="10" onfocus="cal(this);"></td>
          <th>国籍</th>
          <td><input type="text" name="country" value=""></td>
        </tr>
        <tr>
          <th>手机</th>
          <td><input type="text" name="mobile" value="" req="手机号码"></td>
          <th>联系电话</th>
          <td><input type="text" name="phone" value=""></td>
        </tr>
        <tr>
          <th>电子邮件</th>
          <td colspan="3"><input type="text" name="email" value="" class="w2"></td>
        </tr>
        <tr>
          <th>通讯地址</th>
          <td colspan="3"><input type="text" name="address" value="" class="w2"></td>
        </tr>
        <tr>
          <th>备注</th>
          <td colspan="3"><textarea name="memberNote"></textarea></td>
        </tr>
        <tr>
          <th>照片</th>
          <td><input type="hidden" name="memberPhoto" value=""><span id="sp_photo1"></span><input type="button" class="opwin" onclick="showUpload(1);" value="更换.."/></td>
          <th>证件照</th>
          <td><input type="hidden" name="idCardPhoto" value=""><span id="sp_photo2"></span><input type="button" class="opwin" onclick="showUpload(2);" value="更换.."/></td>
        </tr>

</@add.html>